#include <iostream>
#include <memory>
#include <string>
using namespace std;

#include <grpc++/grpc++.h>

#include "grpc_test.grpc.pb.h"
#include "grpc_test.pb.h"

using grpc::Channel;
using grpc::ClientContext;
using grpc::Status;
using grpc_testPack::grpc_testRequest;
using grpc_testPack::grpc_testResponse;
using grpc_testPack::grpc_testServiceCls;

int main(int argc, char **argv) {
  auto channel = grpc::CreateChannel("localhost:50051",
                                     grpc::InsecureChannelCredentials());
  auto stub = grpc_testServiceCls::NewStub(channel);

  grpc_testRequest request;
  grpc_testResponse response;
  ClientContext context;

  Status status = stub->grpc_test(&context, request, &response);

  if (status.ok()) {
    cout << response.res() << endl;
  } else {
    std::cout << status.error_code() << ": " << status.error_message()
              << std::endl;
    cout << "RPC failed" << endl;
  }

  return 0;
}
